package com.ruanyuan.service.impl;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruanyuan.dao.ReplyDao;
import com.ruanyuan.pojo.MessInfo;
import com.ruanyuan.pojo.Reply;
import com.ruanyuan.service.ReplyService;
import com.ruanyuan.utils.Page;

/**
 * 回复业务实现类
 * 
 * @author zbp
 *
 */
@Service
public class ReplyServiceImpl implements ReplyService {
	// 注入回复接口
	@Autowired
	private ReplyDao replyDao;

	/**
	 * 添加回复信息
	 */
	@Override
	public int addReply(Reply reply) {
		// TODO Auto-generated method stub
		return replyDao.addReply(reply);
	}

	/**
	 * 删除回复信息
	 */
	@Override
	public int deleteReply(int id) {
		// TODO Auto-generated method stub
		return replyDao.deleteReply(id);
	}

	/**
	 * 修改回复信息
	 */
	@Override
	public int updateReply(Reply reply) {
		// TODO Auto-generated method stub
		return replyDao.updateReply(reply);
	}

	/**
	 * 查询所有回复信息
	 */
	@Override
	public Page<Reply> getAllReply(@Param("start") Integer page, @Param("rows") Integer rows,
			@Param("remessId") Integer id) {
		// TODO Auto-generated method stub
		Integer page1 = (page - 1) * rows;
		List<Reply> allReplys = replyDao.getAllReply(page1, rows, id);
		int replyNum = replyDao.getReplyNum(id);
		Page<Reply> results = new Page<Reply>();
		// 当前页
		results.setPage(page);
		results.setResult(allReplys);
		// 总数
		results.setTotal(replyNum);
		// 每页显示
		results.setSize(rows);
		return results;
	}

	/**
	 * 根据id查询回复信息
	 */
	@Override
	public Reply getReplyById(int id) {
		// TODO Auto-generated method stub
		return replyDao.getReplyById(id);
	}

	/**
	 * 查询所有回复信息数量
	 */
	@Override
	public int getReplyNum(@Param("remessId") Integer id) {
		// TODO Auto-generated method stub
		return replyDao.getReplyNum(id);
	}

	/**
	 * 根据时间查询回复信息集合
	 * 
	 * @return 回复集合实体类集合
	 */
	@Override
	public Reply getReplyByTime(int id) {
		// TODO Auto-generated method stub
		return replyDao.getReplyByTime(id);
	}

}
